// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import store from '@/store/store.js'

Vue.config.productionTip = false
App.mpType = 'app'

const app = new Vue({
  ...App,
  store // 引入 Vuex store
})

app.$mount()
// #endif

// #ifdef VUE3
import { $http } from '@escook/request-miniprogram'
uni.$http = $http
uni.$showMsg = function(title) {
	uni.showToast({
		title,
		icon: 'none'
	})
}

// 设置请求的根路径
$http.baseUrl = 'https://api.example.com'

// 请求拦截器
$http.beforeRequest = function(options) {
  uni.showLoading({
    title: '数据加载中...'
  })
}

// 响应拦截器
$http.afterRequest = function() {
  uni.hideLoading()
}

import { createSSRApp } from 'vue'
import App from './App'
import store from '@/store/store.js'

export function createApp() {
  const app = createSSRApp(App)
  app.use(store) // 在 Vue 3 中使用 Vuex
  return {
    app
  }
}
// #endif
